﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Menu;
public partial class getip : System.Web.UI.Page
{
    PopulateMenuByUser tes = new PopulateMenuByUser();
    protected void Page_Load(object sender, EventArgs e)
    {
        //if (!IsPostBack)
        //{
            checkBoxChecked();
       // }
        
    }

    protected void checkBoxChecked()
    {
          foreach (Control c in Panel1.Controls)  
             {  
                 if (c is CheckBox)  
                 {  
                     CheckBox cb = (CheckBox)c;
                     if (cb.Checked)
                     {
                         DataSet menu = tes.PopulateParentMenu();
                         for (int menuCount = 0; menuCount < menu.Tables[0].Rows.Count; menuCount++)
                         {
                             int parentMenuId = 0;
                             string parid = menu.Tables[0].Rows[menuCount][1].ToString();
                             parentMenuId = Convert.ToInt16(parid);
                             PopulateSubMenu(parentMenuId);
                             Response.Write(cb.ID);
                         }
                     }
                 }  
             }  
        }

     protected void Page_Init(object sender, EventArgs e)  
     {
         DataSet menu = tes.PopulateParentMenu();
         for (int i = 0; i < menu.Tables[0].Rows.Count; i++)
         {
             CheckBox _checkbox = new CheckBox();
             _checkbox.ID = "chk_" + menu.Tables[0].Rows[i][1].ToString(); 
             _checkbox.Text = menu.Tables[0].Rows[i][2].ToString();
             _checkbox.AutoPostBack = true;
             Panel1.Controls.Add(_checkbox);
         }
     }
     void PopulateSubMenu(int ParentID)
     {

         DataSet menu = tes.PopulateSubMenu(ParentID);
         for (int i = 0; i < menu.Tables[0].Rows.Count; i++)
         {
             CheckBox _checkbox = new CheckBox();
             _checkbox.ID = "chk_" + menu.Tables[0].Rows[i][0].ToString();
             _checkbox.Text = menu.Tables[0].Rows[i][1].ToString();
             _checkbox.AutoPostBack = true;
             Panel1.Controls.Add(_checkbox);
         }
     }
     protected void Chk_CheckedChanged(object sender, EventArgs e)
     {

     }
     protected void chk_CheckedChanged(object sender, EventArgs e)
     {

     }
}
